package com.ympc.service.impl;

import com.ympc.mapper.CourseResourceMapper;
import com.ympc.pojo.CourseResource;
import com.ympc.service.CourseResourceService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseResourceServiceImpl implements CourseResourceService {
    
    @Resource
    private CourseResourceMapper courseResourceMapper;
    
    @Override
    public List<CourseResource> getResourcesByCourseId(Integer courseId) {
        return courseResourceMapper.findByCourseId(courseId);
    }
    
    @Override
    public List<CourseResource> getResourcesByCourseIdAndType(Integer courseId, String resourceType) {
        return courseResourceMapper.findByCourseIdAndType(courseId, resourceType);
    }
    
    @Override
    public CourseResource getResourceById(Integer id) {
        return courseResourceMapper.findById(id);
    }
    
    @Override
    public boolean createResource(CourseResource resource) {
        return courseResourceMapper.insertResource(resource) > 0;
    }
    
    @Override
    public boolean updateResource(CourseResource resource) {
        return courseResourceMapper.updateResource(resource) > 0;
    }
    
    @Override
    public boolean deleteResource(Integer id) {
        return courseResourceMapper.deleteResource(id) > 0;
    }
    
    @Override
    public boolean deleteResourcesByCourseId(Integer courseId) {
        return courseResourceMapper.deleteByCourseId(courseId) > 0;
    }
}

